//
//  MyCategoryCell.m
//  JianChaRiBao
//
//  Created by Changxy on 13-5-28.
//  Copyright (c) 2013年 wzyk. All rights reserved.
//

#import "MyCategoryCell.h"
#import "UIImageView+WebCache.h"
#import "MyImageView.h"
@implementation MyCategoryCell
@synthesize image1, image2, image3, dataArray;

-(void)dealloc{
    [self.image1 release];
    [self.image2 release];
    [self.image3 release];
    [dataArray release];
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}
-(void)setImageWitharray:(NSArray *)array{
    
    dataArray = [[NSArray alloc]initWithArray:array];
    
    if (array.count > 0) {
        [self.image1 setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:0] objectForKey:@"image"]] placeholderImage:[UIImage imageNamed:@"default_image.png"]];
        self.image1.tag = 0;
        self.image1.layer.shadowColor = [UIColor blackColor].CGColor;
        self.image1.layer.shadowOpacity = 0.45;
        self.image1.layer.shadowOffset = CGSizeMake(0, 6);
        self.image1.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.image1.bounds].CGPath;
        self.image1.layer.masksToBounds = NO;
        [self.image1 addTarget:self action:@selector(imageClicked:)];
    }
    if (array.count > 1) {
        [self.image2 setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:1] objectForKey:@"image"]] placeholderImage:[UIImage imageNamed:@"default_image.png"]];
        self.image2.tag = 1;
        self.image2.layer.shadowColor = [UIColor blackColor].CGColor;
        self.image2.layer.shadowOpacity = 0.45;
        self.image2.layer.shadowOffset = CGSizeMake(0, 6);
        self.image2.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.image2.bounds].CGPath;
        self.image2.layer.masksToBounds = NO;
        [self.image2 addTarget:self action:@selector(imageClicked:)];


    }
    if (array.count > 2) {
        [self.image3 setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:2] objectForKey:@"image"]] placeholderImage:[UIImage imageNamed:@"default_image.png"]];
        self.image3.tag = 2;
        self.image3.layer.shadowColor = [UIColor blackColor].CGColor;
        self.image3.layer.shadowOpacity = 0.45;
        self.image3.layer.shadowOffset = CGSizeMake(0, 6);
        self.image3.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.image3.bounds].CGPath;
        self.image3.layer.masksToBounds = NO;
        [self.image3 addTarget:self action:@selector(imageClicked:)];
    }

}
-(void)imageClicked:(MyImageView *)image{
    NSDictionary * dict = [dataArray objectAtIndex:image.tag];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MyCategoryCellClicked" object:dict];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
